﻿using Cherry.Agile.Enterprise.Entity;
using Cherry.Agile.Enterprise.Entity.Enum;
using Cherry.Agile.Framework.Query;
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Text;
using System.Threading.Tasks;

namespace Cherry.Agile.Enterprise.Services.Interface
{
    /// <summary>
    /// 员工服务接口
    /// 谢韶光
    /// 2014-05-31
    /// </summary>
    [ServiceContract(Namespace = Unity.Namespace)]
    public interface IStaffService
    {

        /// <summary>
        /// 获取所有员工信息
        /// </summary>
        /// <returns>员工信息</returns>
        [OperationContract]
        List<StaffInfo> SyncStaffInfo();

        /// <summary>
        /// 获取所有员工信息
        /// </summary>
        /// <returns>员工信息</returns>
        [OperationContract]
        List<StaffInfo> GetStaffs();

        /// <summary>
        /// 根据姓名获取员工详细信息
        /// </summary>
        /// <param name="StaffName">员工姓名</param>
        /// <returns>员工信息实体</returns>
        [OperationContract]
        StaffInfo GetStaffInfoByName(string StaffName);

        /// <summary>
        /// 增加员工
        /// </summary>
        /// <param name="Staff">员工实体</param>
        [OperationContract]
        StaffInfo AddStaff(StaffInfo StaffInfo);

        /// <summary>
        /// 导入员工
        /// </summary>
        /// <param name="StaffInfoList">员工实体列表</param>
        /// <param name="departmentList">部门ID列表</param>
        [OperationContract]
        void ImportStaffInfo(List<StaffInfo> StaffInfoList, List<int> departmentList);

        /// <summary>
        /// 逻辑批量删除员工
        /// </summary>
        /// <param name="StaffIdArray">员工ID数组</param>
        [OperationContract]
        void DeleteStaffLogic(int[] StaffIdArray);


        /// <summary>
        /// 根据员工ID，返回员工名列表
        /// </summary>
        /// <param name="StaffIdArray">员工名称ID数组</param>
        /// <returns>员工名 </returns>
        [OperationContract]
        List<string> GetStaffNameByEmpIdArray(int[] StaffIdArray);

        /// <summary>
        /// 修改员工
        /// </summary>
        /// <param name="Staff">员工实体</param>
        [OperationContract]
        void UpdateStaff(StaffInfo StaffInfo);

        /// <summary>
        /// 查询员工信息列表
        /// </summary>
        /// <param name="name">名字 为空忽略</param>
        /// <param name="workId">工号 为空忽略</param>
        /// <param name="orgId">单位 不大于零忽略条件</param>
        /// <param name="department">部门 不大于零忽略条件</param>
        /// <param name="position">职务  不大于零忽略条件</param>
        /// <param name="pagination">分页信息</param>
        /// <returns>员工列表信息</returns>
        [OperationContract]
        List<StaffInfo> GetStaffList(string name, string workId, int orgId, int department, int position, Pagination pagination);


        /// <summary>
        /// 员工用户登陆
        /// </summary>
        /// <param name="account">员工登陆账号</param>
        /// <param name="password">员工登陆密码</param>
        /// <returns>员工实体</returns>
        [OperationContract]
        StaffInfo StaffLogin(string account, string password);

        /// <summary>
        /// 查询员工角色关系列表
        /// </summary>
        /// <param name="StaffID">员工ID</param>
        /// <returns>员工角色关系列表</returns>
        [OperationContract]
        List<RoleStaffInfo> GetStaffRoleListByStaffId(int StaffId);
        /// <summary>
        /// 添加用户角色关系表信息
        /// </summary>
        /// <param name="StaffRoleRel">关联信息</param>
        [OperationContract]
        void AddStaffRole(RoleStaffInfo StaffRoleRel);

        /// <summary>
        /// 修改用户角色关系表信息
        /// </summary>
        /// <param name="StaffRoleRel">关联信息</param>
        [OperationContract]
        void UpdateStaffRole(RoleStaffInfo StaffRoleRel);

        /// <summary>
        /// 删除用户角色关系表信息
        /// </summary>
        /// <param name="StaffRoleId">关联ID</param>
        [OperationContract]
        void DeleteStaffRole(int StaffRoleId);

        /// <summary>
        /// 获取指定员工的菜单列表
        /// </summary>
        /// <returns>菜单列表信息</returns>
        [OperationContract]
        List<MenuInfo> GetStaffMenuList(int StaffId);


        /// <summary>
        /// 批量激活/冻结员工用户
        /// </summary>
        /// <param name="StaffIdArray">员工ID数组</param>
        /// <param name="freezeOrActive">激活/冻结</param>
        [OperationContract]
        void FreezeOrActiveStaff(int[] StaffIdArray, FreezeOrActiveEnum freezeOrActive);

        /// <summary>
        /// 重置员工密码
        /// </summary>
        /// <param name="StaffId">员工ID</param>
        [OperationContract]
        void ResetStaffPassword(int StaffId);

        /// <summary>
        /// 根据单位ID获取该单位的员工信息
        /// </summary>
        /// <param name="orgID">单位ID（不是部门）</param>
        /// <returns></returns>
        [OperationContract]
        List<StaffInfo> GetStaffListDefaultByOrgID(int orgID);

        /// <summary>
        /// 根据OrgId 获取其下所相关的员工
        /// </summary>
        /// <param name="orgId">组织Id</param>
        /// <param name="isContainUnderOrg">是否需要包含对下级组织的查询</param> 
        /// <returns>员工列表</returns>
        [OperationContract]
        List<StaffInfo> GetStaffListAndUnderByOrgId(int orgId, bool isContainUnderOrg);

        /// <summary>
        /// 获取符合病人的员工信息列表 房添加
        /// </summary>
        /// <param name="dots">员工列表</param>
        /// <returns>员工信息列表</returns>
        [OperationContract(Name = "GetStaffListByIds")]
        List<StaffInfo> GetStaffList(List<int> dots, Pagination pagination);

        /// <summary>
        /// 修改员工密码
        /// </summary>
        /// <param name="StaffID"></param>
        /// <param name="pwd"></param>
        [OperationContract]
        void UpdataPassword(int StaffID, string pwd);


        /// <summary>
        /// 判断是否存在相同的 用户名
        /// </summary>
        /// <param name="StaffAccount">员工账号</param>
        /// <returns>true 存在</returns>
        [OperationContract]
        bool IsExistEmpAccount(string StaffAccount);



        /// <summary>
        /// 判断是否存在相同的证件
        /// </summary>
        /// <param name="credType">证件类型</param>
        /// <param name="credNO">证件号码</param>
        /// <returns>true 存在</returns>
        [OperationContract]
        bool IsExistCredNO(sbyte credType, string credNO);

        /// <summary>
        /// 判断是否存在相同的工号
        /// </summary>
        /// <param name="credType">单位编号</param>
        /// <param name="credNO">工号</param>
        /// <returns>true 存在</returns>
        [OperationContract]
        bool IsWorkIdExists(int unitId, string workId);


        ///// <summary>
        ///// 员工列表页面查询
        ///// </summary>
        ///// <param name="EmpViewQuery">查询条件</param>
        ///// <param name="pagination">分页信息</param>
        ///// <returns>显示列表信息</returns>
        //[OperationContract]
        //List<StaffListView> GetEmpListView(StaffViewQuery EmpViewQuery, Pagination pagination);

        ///// <summary>
        ///// 获取用来导出的员工信息
        ///// </summary>
        ///// <param name="EmpViewQuery">查询条件</param>
        ///// <param name="rowCount">导出的行数</param>
        ///// <returns>员工信息列表</returns>
        //[OperationContract]
        //List<StaffInfo> GetStaffExportList(StaffViewQuery EmpViewQuery, int rowCount);

        ///// <summary>
        ///// 获取员工简单实体
        ///// </summary>
        ///// <param name="StaffName">员工姓名</param>
        ///// <param name="orgID">组织ID</param>
        ///// <param name="paging"></param>
        ///// <returns></returns>
        //[OperationContract]
        //List<StaffSimplifyInfo> GetStaffsimplifyList(int currentUserId, string StaffName, int orgID, Pagination paging);

        /// <summary>
        /// 根据员工名字和分组查询分组内的员工显示信息
        /// </summary>
        /// <param name="empName">员工名字</param>
        /// <param name="groupId">分组ID</param>
        /// <param name="pagination">分页信息</param>
        /// <returns>分组内员工信息</returns>
        //[OperationContract]
        //List<GroupStaffListView> GetGroupEmpListViewByGroupId(string empName, int groupId, Pagination pagination);

        /// <summary>
        /// 获取属于某个组织的，可以操作某些组织的员工
        /// </summary>
        /// <param name="orgBelongTo">所属组织</param>
        /// <param name="operableOrg">可操作组织</param>
        /// <returns></returns>
        [OperationContract]
        List<StaffInfo> GetStaffListByOperableOrg(int orgBelongTo, List<int> operableOrg);

        /// <summary>
        /// 根据分组列表，
        ///  得到》》指定的组织列表有操作权限的》》》员工列表
        /// </summary>
        /// <param name="operableOrg">有操作权限的组织列表</param>
        /// <param name="groupids">分组列表</param>
        /// <returns>员工ID列表</returns>
        [OperationContract]
        List<int> GetStaffListByOperableOrgs(List<int> operableOrg, List<int> groupids);

        /// <summary>
        /// 删除员工的权限信息。清除员工的 角色信息，和分组信息
        /// </summary>
        /// <param name="empId">员工ID</param>
        [OperationContract]
        void ClearStaffRelInfo(int empId);
    }
}
